﻿﻿@extends('admin.Default')
@section('type')
    <link href="{{ asset('myadmin/css/plugins/dataTables/dataTables.bootstrap.css') }}" rel="stylesheet">
@stop
@section('content')
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <input type='hidden' name='_token' value='{{ csrf_token() }}'>
                        <table class="table table-striped table-bordered table-hover dataTables-example">
                            <thead>
                            <tr >
                                <th >订单编号</th>
                                <th >商家编号</th>
                                <th >下单时间</th>
                                <th >订单状态</th>
                                <th >收货人</th>
                                <th >收货人电话</th>
                                <th >收货人地址</th>
                                <th >支付方式</th>
                                <th >实付款</th>
                                <th >审核医师</th>
                                <th >配送员</th>
                                <th >订单备注</th>
                                <th >&nbsp;&nbsp;&nbsp;操&nbsp;&nbsp;&nbsp;作&nbsp;&nbsp;</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($list as $v)
                                    <tr>
                                        <td>{{ $v->number }}</td>
                                        <td>{{ $v->store_id }}</td>
                                        <td>{{ $v->created_at }}</td>
                                        <td>以删除</td>
                                        <td>{{ $v->name }}</td>
                                        <td>{{ $v->phone }}</td>
                                        <td>{{ $v->address }}</td>
                                        <td>{{ $v->paymethod == 1 ? '支付宝付款':($v->paymethod == 2?'微信付款':'货到付款') }}</td>
                                        <td>{{ $v->realpay }}</td>
                                        <td>{{ $v->doctor_id }}</td>
                                        <td>{{ $v->sender_id }}</td>
                                        <td>{{ $v->remark }}</td>
                                        <td>
                                            <a onclick="doaddress({{ $v->id }},'{{ $v->number }}',{{ $v->amount }},{{ $v->discount }},{{ $v->carriage }},{{ $v->realpay }});" data-toggle="modal" class="" href="#modal-form-one"  >订单详情</a> |
                                            <a>取消删除</a>
                                        </td>
                                    </tr>
                            @endforeach
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="modal-form-one" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <h5 id="order"></h5>
                                    <h5 id="order_info"></h5>
                                    <div class="ibox-tools">
                                        <a class="collapse-link">
                                            <i class="fa fa-chevron-up"></i>
                                        </a>

                                    </div>
                                </div>
                                <div class="ibox-content ">

                                    <table class="table table-bordered order">
                                        <thead>
                                        <tr>
                                            <th >药品编号</th>
                                            <th >药品名称</th>
                                            <th >药品单价</th>
                                            <th >药品数量</th>
                                            <th >药品规格</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Mainly scripts -->
@stop
@section('script')
    <script type="text/javascript" src="{{ asset('myadmin/js/jquery.min.js') }}"></script><script type="text/javascript"  src="{{ asset('myadmin/js/jquery-2.1.1.min.js') }}"></script>
    <script type="text/javascript" src="{{ asset('myadmin/js/bootstrap.min.js?v=3.4.0') }}"></script>
    <script type="text/javascript" src="{{ asset('myadmin/js/plugins/metisMenu/jquery.metisMenu.js') }}"></script>
    <script type="text/javascript" src="{{ asset('myadmin/js/plugins/slimscroll/jquery.slimscroll.min.js') }}"></script>
    <!-- iCheck -->
    <script type="text/javascript" src="{{ asset('myadmin/js/plugins/iCheck/icheck.min.js') }}"></script>
    <script type="text/javascript" src="{{ asset('myadmin/js/plugins/dropzone/dropzone.js') }}"></script>

    <script type="text/javascript" src="{{ asset('myadmin/js/plugins/jeditable/jquery.jeditable.js') }}"></script>

    <!-- Data Tables -->
    <script type="text/javascript" src="{{ asset('myadmin/js/plugins/dataTables/jquery.dataTables.js') }}"></script>
    <script type="text/javascript" src="{{ asset('myadmin/js/plugins/dataTables/dataTables.bootstrap.js') }}"></script>
    <script type="text/javascript">

        //订单详情
        function doaddress(id, number, amount, discount, carriage ,realpay)
        {
            $('.order tbody').children().remove();
            $.ajax({
                url:'{{ url("admin/user/ajax/selorder") }}',
                async:false,				//是否异步
                type:'post',				//请求方式
                data:{id:id, status:status,  '_token': $('input[name=_token]').val()},				//发送的数据
                dataType:'json',			//响应的数据类型
                success:function(data)		//成功时回调函数
                {
                    if(data == null){
                        $('.order').css('display','none');
                        $('#order_info').css('display','none');
                        $('#order').html('订单：'+ number +' 信息查询失败请稍候重试');
                    }else{
                        $('.order').css('display','');
                        $('#order_info').css('display','');
                        $('#order').html('订单：'+ number +' 详细信息如下：');
                        $('#order_info').html('药品总价：'+ amount +' - 优惠金额：'+ discount +' + 运费:'+ carriage +' = 付款金额：'+ realpay);
                        for (var i = 0; i < data.length; i++) {
                            $('.order tbody').append("<tr><td>"+data[i].product_id+"</td><td>"+data[i].name+"</td><td>"+data[i].price+"</td><td>"+data[i].count+"</td><td>"+data[i].specifications+"</td></tr>");
                        };
                    }
                }
            });
        }


        $(document).ready(function () {
            $('.dataTables-example').dataTable();
            var oTable = $('#editable').dataTable();
            oTable.$('td').editable('../example_ajax.php', {
                "callback": function (sValue, y) {
                    var aPos = oTable.fnGetPosition(this);
                    oTable.fnUpdate(sValue, aPos[0], aPos[1]);
                },
                "submitdata": function (value, settings) {
                    return {
                        "row_id": this.parentNode.getAttribute('id'),
                        "column": oTable.fnGetPosition(this)[2]
                    };
                },
                "width": "90%",
                "height": "100%"
            });
        });
    </script>

@stop